import React from 'react'
import { connect } from '@umijs/max'

function Home(props) {
  const {
    envInfo,
    dispatch
  } = props
  console.log(props);
  const handleChangeEnv = () => {
    dispatch({
      type: 'global/save',
      payload: {
        envInfo: '预发'
      }
    })
  }
  return (
    <div>
      Home Page
      <button onClick={handleChangeEnv}>dispatch</button>
      <br />
      <h2>环境：{envInfo}</h2>
    </div>
  )
}

export default connect(({ global }: { global: any }) => {
  return {
    envInfo: global.envInfo
  }
})(Home)
